Next | Prev | Up | Top | Contents | Index

Transferring Data Through a uio_t Object

A uio_t object defines a list of one or more segments in the address space of the kernel or a user process (see "Structure uio_t"). The kernel supplies three functions for transferring data based on a uio_t, and these are summarized in Table 9-8.

Functions Moving Data Using uio_t
FunctionHeader FilesCan Sleep?Purpose
uiomove(D3) ddi.hYCopy data using uio_t.
ureadc(D3) ddi.hYCopy a character to space described by uio_t.
uwritec(D3) ddi.hYReturn a character from space described by uio_t.

The uiomove() function moves multiple bytes between a buffer in kernel virtual space--typically, a buffer owned by the driver--and the space or spaces described by a uio_t. The function takes a byte count and a direction flag as arguments, and uses the most efficient mechanism for copying.

The ureadc() and uwritec() functions transfer only a single byte. You would use them when transferring data a byte at a time by PIO. When moving more than a few bytes, uiomove() is faster.

All of these functions modify the uio_t to reflect the transfer of data:

The result is that the state of the uio_t always reflects the number of bytes remaining to transfer. When the pfxread() or pfxwrite() entry point returns, the kernel uses the finsl value of ui_resid to compute the count returned to the read() or write() function call.


Next | Prev | Up | Top | Contents | Index